﻿#pragma once

#include <qtreewidget.h>
#include <qvector.h>

class ScriptRunner;

class TreeWidget_EditScriptList : public QTreeWidget
{
  Q_OBJECT
public:
  enum ListOperation
  {//针对脚本列表的操作
    Clone = 0,
    MoveUp = 1,
    MoveDown = 2,
    Remove = 3
  };
private:
  QTreeWidgetItem* previousItem = Q_NULLPTR;
  ScriptRunner* scriptRunner = Q_NULLPTR;
public:
  TreeWidget_EditScriptList(QWidget* parent = Q_NULLPTR);
  ~TreeWidget_EditScriptList();
private:
  void circularDelete(QTreeWidgetItem* parent);

public:
  bool updateScriptList();
  bool showScriptList();
  void itemOperation(ListOperation operationFlag);
private slots:
  void slot_itemClicked(QTreeWidgetItem* item, int column);
public:
  //添加新的指令到脚本预览
  void addOperationNameToList(QString name);

  //geter and seter
public:
  ScriptRunner* getScriptRunner();
  void setScriptRunner(ScriptRunner* scriptRunner);
};
